package level4.tools
{
	import flash.utils.ByteArray;

	public class CharacterTool
	{
		public static const Instance:CharacterTool = new CharacterTool();
		private var bytes:ByteArray;
		
		public function CharacterTool()
		{
		}
		
		public function isChinese(str:String):Boolean{
			bytes = new ByteArray();
			bytes.writeUTFBytes(str);
			bytes.position = 0;
			return bytes.readByte() < 0;
		}
		public function getEnCnCharacters(str:String):Array{
			return str.match(/[\w\u4E00-\u9FA5]/g);
		}
		/**
		 * 将str中的targetStr替换为replStr
		 * 
		 * str 
		 * replaceStr 如 \\[abc\\]
		 * targetStr
		 * */
		public function replaceAll(str:String,:String,:String):String{
			return str.replace(new RegExp(targetStr,"g"),replStr);
		}
		
	}
}